<% add_decidim_page_title(t(".title")) %>
<div class="card">
  <div class="item_show__header">
    <h1 class="item_show__header-title">
      <%= t(".title") %>
      <%= link_to t("actions.new_status", scope: "decidim.accountability"), new_status_path, class: "button button__sm button__secondary" if allowed_to? :create, :status %>
    </h1>
  </div>
  <div class="table-stacked">
    <table class="table-list">
      <thead>
        <tr>
          <th><%= sort_link(query, :key, t("models.status.fields.key", scope: "decidim.accountability")) %></th>
          <th><%= sort_link(query, :name, t("models.status.fields.name", scope: "decidim.accountability")) %></th>
          <th><%= t("models.status.fields.description", scope: "decidim.accountability") %></th>
          <th><%= sort_link(query, :progress, t("models.status.fields.progress", scope: "decidim.accountability")) %></th>
          <th><%= t("actions.title", scope: "decidim.accountability") %></th>
        </tr>
      </thead>
      <tbody>
        <% statuses.each do |status| %>
          <tr data-id="<%= status.id %>">
            <td data-label="<%= t("models.status.fields.key", scope: "decidim.accountability") %>">
              <%= status.key %>
            <br></td>
            <td data-label="<%= t("models.status.fields.name", scope: "decidim.accountability") %>">
              <%= translated_attribute(status.name) %>
            </td>
            <td data-label="<%= t("models.status.fields.description", scope: "decidim.accountability") %>">
              <%= truncate translated_attribute(status.description), length: 50 %>
            </td>
            <td data-label="<%= t("models.status.fields.progress", scope: "decidim.accountability") %>">
              <%= status.progress %>
            </td>
            <td class="table-list__actions" data-label="<%= t("actions.title", scope: "decidim.accountability") %>">
              <button type="button" data-controller="dropdown" data-target="actions-status-<%= status.id %>" aria-label="<%= t("decidim.admin.actions.actions_label", resource: t("models.status.name", scope: "decidim.accountability.admin")) %>">
                <%= icon "more-fill", class: "text-secondary" %>
              </button>

              <div class="inline-block relative">
                <ul id="actions-status-<%= status.id %>" class="dropdown dropdown__action" aria-hidden="true">
                  <% if allowed_to? :update, :status, status: status %>
                    <li class="dropdown__item">
                      <%= link_to edit_status_path(status), class: "dropdown__button" do %>
                        <%= icon "pencil-line" %>
                        <%= t("actions.edit", scope: "decidim.accountability") %>
                      <% end %>
                    </li>

                    <hr>
                  <% end %>

                  <% if allowed_to? :destroy, :status, status: status %>
                    <li class="dropdown__item">
                      <%= link_to status_path(status), method: :delete, data: { confirm: t("actions.confirm_destroy", scope: "decidim.accountability", name: t("models.status.name", scope: "decidim.accountability.admin")) }, class: "dropdown__button dropdown__button--danger" do %>
                        <%= icon "delete-bin-line" %>
                        <%= t("actions.destroy", scope: "decidim.accountability") %>
                      <% end %>
                    </li>
                  <% end %>
                </ul>
              </div>
            </td>
          </tr>
        <% end %>
      </tbody>
    </table>
  </div>
</div>
<%= decidim_paginate statuses %>
